﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using WebsiteClient.Models;
using WebsiteClient.DB;
using System.Threading;

namespace WebsiteClient.ApiControllers
{
    public class EventController : ApiController
    {
        private static EventDB eventDb = new EventDB();
        private List<Event> list = new List<Event>();
        
        DateTime now = DateTime.Now;
        DateTime start = DateTime.Now.AddSeconds(10);

        public EventController()
        {
            
        }        

        // GET: api/Event
        public IEnumerable<Event> Get()
        {
            list = new List<Event>();
            foreach (var item in eventDb.FindAllEvents())
            {
                Event newEvent = new Event();
                newEvent.EventId = item.EventId;
                newEvent.Title = item.Title;
                newEvent.Description = item.Description;
                newEvent.Address = item.Address;
                newEvent.ZipCode = item.ZipCode;
                newEvent.City = item.City;
                newEvent.Price = item.Price;
                newEvent.Date = item.Date;
                newEvent.Time = item.Time;

                list.Add(newEvent);
            }
            return list;
        }

        // GET: api/Event/5
        public string Get(int id)
        {
            return "value";
        }

        // POST: api/Event
        [HttpPost]
        public void Post([FromBody] Event newEvent)
        {
            
        }

        // PUT: api/Event/5
        public void Put(int id, [FromBody]string value)
        {
        }

        // DELETE: api/Event/5
        public void Delete(int id)
        {
        }

        public void AddEvent(Event newEvent)
        {
            eventDb.AddEvent(newEvent);
        }

    //    public object GetFirstEvent()
    //    {
    //        return eventDb.GetFirstEvent();
    //    }

    //    public void DeleteEvent(Event removedEvent)
    //    {
    //        eventDb.DeleteEvent(removedEvent);
    //    }

    //    public Event FindEventByTitle(string title)
    //    {
    //        return eventDb.FindEventByTitle(title);
    //    }

    //    public List<Event> FindAllEvents()
    //    {
    //        return eventDb.FindAllEvents();
    //    }


    }
}
